package com.weiaibenpao.demo.chislim.ui.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;

import com.orhanobut.logger.Logger;
import com.weiaibenpao.demo.chislim.R;
import com.weiaibenpao.demo.chislim.base.BaseFragment;
import com.weiaibenpao.demo.chislim.ui.adapter.RunningFragmentAdapter;
import com.weiaibenpao.demo.chislim.ui.widget.CustomViewPager;
import com.weiaibenpao.demo.chislim.utils.TabLayoutIndicatorWeight;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/12/4.
 */

public class RunningFragment extends BaseFragment {

    @BindView(R.id.tabLayout)
    TabLayout mTab;
    @BindView(R.id.view_pager)
    CustomViewPager mVp;
    private ArrayList<String> titles = new ArrayList<>();
    private List<Fragment> mFragmentList=new ArrayList<>();

    private RunningFragmentAdapter  adapter;
    private NormalRunFragment normalRunFragment;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
    }




    @Override
    public int getLayoutId() {
        return R.layout.fragment_running;
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        titles.add("常规");
        titles.add("中国");
        titles.add("趣味");
        normalRunFragment = new NormalRunFragment();
        mFragmentList.add(normalRunFragment);
        mFragmentList.add(new ChinaRunFragment());
        mFragmentList.add(new InterestRunFragment());
        initVp();
    }



    private void initVp() {
        adapter=new RunningFragmentAdapter(getChildFragmentManager(),mFragmentList,titles);
        mVp.setAdapter(adapter);
        mVp.setOffscreenPageLimit(3);
        mTab.setupWithViewPager(mVp);
        TabLayoutIndicatorWeight.setIndicator(mTab,43,43);
    }

    @Override
    public void onResume() {
        super.onResume();
        Logger.e("RunningFragment");
    }
}
